(ns blade-art-online.core.skills-test
 (:require [clojure.test :refer :all]
           [blade-art-online.core.skills :refer :all]))


(deftest test-vertical-chop-effect
 (is
  (= (spawn-effect :damage 15)
     (vertical-chop-effect {:str 10}))))

(deftest test-add-buff
 (is
  (= {:buffkeys [:once-shield]}
     (add-buff :once-shield {:buffkeys []}))))

(deftest test-damage
 (is
  (= {:hp 90}
     (damage 10 {:hp 100}))))

(deftest vertical-chop
 (let [produce-effect (get-in skills [:vertical-chop :produce-effect])
       kirito {:str 100}]
      (is
        (= (spawn-effect :damage 60)
           (produce-effect {:src kirito})))))

(deftest once-shield
 (let [affect (get-in skills [:once-shield :affect])]
      (is
        (= {:tar {:buffkeys [:once-shield]}}
           (affect {:tar {:buffkeys []}})))))

(deftest test-skills
 (vertical-chop)
 (once-shield))

(deftest once-shield
 (let [before-affect (get-in buffs [:once-shield :before-affect])
       obj-with-safe-effect {:effect (spawn-effect)}]
      (is
       (= obj-with-safe-effect
          (before-affect {:effect (spawn-effect :damage 10)})))
      (is
       (= obj-with-safe-effect
          (before-affect {:effect (spawn-effect :damage 0)})))))

(deftest poison
 (let [spell (get-in buffs [:poison :spell])]
   (is
    (= {:src {:hp 90}}
       (spell {:src {:hp 100}})))))

(deftest test-buffs
 (once-shield)
 (poison))